<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix='fmt'%>
<%@ taglib uri="/tags/trymore" prefix="tm"%>

<script type="text/javascript">
	function callback_groupRemove(id) {
		if ($("#group-" + id).size() > 0) {
			$("#group-" + id).fadeOut("slow");
		}
	}
	
	$("#export_ccard").click(function(){
		$.post("app/card/business.do?action=actionExportBusinessCard", {
			"companyName"	: $("#q_ccardCompanyName").val(),
			"contactPerson"	: $("#q_ccardContactPerson").val(),
			"industryId"	: $("#q_ccardIndustryId").val(),
			"projectNo"		: $("#q_ccardProjectNo").val()
		}, function(rsp){
			var feedback = eval('(' + rsp + ')');
			if (feedback.status && feedback.status == 200) 
			{
				var windowAttr = "location=yes,statusbar=no,directories=no,menubar=no,titlebar=no,toolbar=no,dependent=no,resizable=yes,personalbar=no,scrollbars=yes"; 
				window.open("file-download?path="+feedback.file+"&filename="+feedback.name, "_blank",  windowAttr);
			} 
			else 
			{
				// error message migtht be raised here.
				alert(feedback.message);
			}
		});
	});
</script>

<div id="group_wrapper">
	<form id="pagerForm" method="post" action="app/card/business.do?action=pageBusinessCardIndex">
		<input type="hidden" name="pageNum" value="${pagingBean ne null ? pagingBean.currentPage : 1}" />
		<input type="hidden" name="numPerPage" value="${pagingBean ne null ? pagingBean.pageSize : 20}" />
	</form>
	
	<!-- SearchBar -->
	<div class="pageHeader">
		<form onsubmit="return navTabSearch(this);" action="app/card/business.do?action=pageBusinessCardIndex" 
			method="post" id="searchForm" rel="pagerForm">
			<div class="searchBar">
				<table class="searchContent">
					<tr>
						<td>
							<label>企业名称：</label>
							<input type="text" id="q_ccardCompanyName" name="companyName" rel="pagerForm" value="${companyName ne null ? companyName : ''}" />
						</td>
						<td>
							<label>联系人：</label>
							<input name="contactPerson" id="q_ccardContactPerson" rel="pagerForm" value="${contactPerson ne null ? contactPerson : ''}" />
						</td>
						<td>
							<label>行业：</label>
							<select name="industryId" id="q_ccardIndustryId" class="combox">
								<option value="">所有</option>
								<logic:present name="industry">
									<logic:iterate name="industry" id="dict">
										<option value="${dict.id}" ${industryId ne null && industryId eq dict.id ? 'selected' : ''}>${dict.dictKey}</option>
									</logic:iterate>
								</logic:present>
							</select>
						</td>
						<td>
							<label>项目编号：</label>
							<input type="text" id="q_ccardProjectNo" name="projectNo" rel="pagerForm" value="${projectNo ne null ? projectNo : ''}" />
						</td>
					</tr>
				</table>
				<div class="subBar">
					<ul>
						<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
					</ul>
				</div>
			</div>
		</form>
	</div>
	
	<!-- Body -->	
	<div class="pageContent">
		<div class="panelBar">
			<ul class="toolBar">
				<li>
					<a class="add" href="app/card/business.do?action=dialogBusinessCard" 
						target="dialog" title="添加新企业名片" mask="true" width="615" height="390" rel="dia_card_business_add">
						<span>添加新企业名片</span>
					</a>
				</li>
				<li>
					<a class="delete" href="app/card/business.do?action=dialogBusinessCardImportPage" 
						target="dialog" title="导入企业名片" mask="true" width="445" height="238" rel="dia_card_business_import">
						<span>导入企业名片</span>
					</a>
				</li>
				<li>
					<a class="icon" id="export_ccard" href="javascript:void(0);" title="导出企业名录">
						<span>导出企业名片</span>
					</a>
				</li>
			</ul>
		</div>
		
		<%@ include file="datagrid/dataGridBusinessCard.jsp" %>
		
	</div>
</div>